[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 close()                 Close File

 #include <io.h>                         Required for declarations only

 int        close(handle);
 int        handle;                      Handle referring to open file

    close() closes the file associated with a file handle, 'handle'
    obtained with a previous _creat(), creat(), creatnew(), creattemp(),
    dup(), dup2(), _open() or open() call.  If the file is a text file,
    close() does not add a Control-Z character to the end of the file.

    Returns:    0 if successful.  If an invalid file handle was given, -1
                is returned and 'errno' is set to EBADF (bad file
                number).

   -------------------------------- Example ---------------------------------

    This example opens a file for reading and writing, then closes it.

           #include <io.h>
           #include <fcntl.h>

           int fhndl;

           main()
           {
               fhndl = open("data",O_RDWR);
                .
                .
                .
               close(fhndl);
           }



See Also: creat() dup() dup2() open() unlink()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson